#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<assert.h>



char* strncpy(char* p,const char* q,int n)
{
	assert(p);
	assert(q);
	int i = 0;
	int j = 0;
	while (q[j]&&i<n)
	{
		p[i++] = q[j++];
	}
	p[i] = '\0';
	return p;
}

char* strncat(char* p, const char* q, int n)
{

	assert(p);
	assert(q);
	int i = 0, j = 0;
	while (p[i])
	{
		i++;
	}
	while (q[j]&&j<n)
	{
		p[i++] = q[j++];
	}
	p[i] = '\0';
	return p;
}

void* memcpy(void* p, const void* q, int size)
{
	assert(p);
	assert(q);
	char* x = (char*)p;
	char* z = (char*)q;
	int i = 0, j = 0;
	while (i < size)
	{
		x[i++] = z[j++];
	}
	return p;
}

void* memmove(void* p, const void* q,int size)
{
	assert(p);
	assert(q);
	char* x = (char*)p;
	char* z = (char*)q;
	int i = 0, j = 0;
	if (x <= z)
	{
		while (i < size)
		{
			x[i++] = z[j++];
		}
	}
	else
	{
		i = size - 1; j = size - 1;
		while (i >=0)
		{
			x[i--] = z[j--];
		}
	}
	return p;
}

size_t strlen(const char* p)
{
	size_t count = 0;
	while (*p)
	{
		count++;
		p++;
	}
	return count;
}

void strcmp(char* p, const char* q)
{
	while (*q)
	{

	}
}


int main()
{
	char p[20] = { "shdgsuihd" };
	char q[10] = { "xxxxx0xxx" };
	int z[20] = { 1,2,3,4,5,6,7,8,9};
	float x[10] = { 2.2,2.2,2.2,2.2,44};
	memmove(z+1, z,16);
	size_t c=strlen(p);
	int i = 0;
	printf("%zd\n ", c);
	//for(i=0;i<20;i++)
	//printf("%d ",z[i]);
	//printf(q);
}
